package com.aryankh.configuration;

import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

/**
 * @version 1.0
 * @Author AryanKH
 * @Date 2022/6/4 18:59
 * @Default
 */
@Configuration
public class ThreadPoolConfiguration {
    @Bean
    public ExecutorService executorService() {
        return new ThreadPoolExecutor(10, 20,
                120L, TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(100),
                new BasicThreadFactory.Builder().namingPattern("khlog-%d")
                        .daemon(true).build(), new ThreadPoolExecutor.AbortPolicy());
    }


}
